let el="";
let nav=document.querySelector(".nav")
fetch("http://chst.vip:1234/api/getbaicaijiatitle")
.then(body=>body.json())
.then(res=>{
    console.log(res.result)
    res.result.forEach(item=>{
        el+=`<a href="baicaijia.html?titleid=${item.titleId}">${item.title}</a>`
        
    })
    
    nav.innerHTML=el;
})

let id=getQueryString('titleid')
console.log(id)
//二次获取
let ela="";
let uu=document.querySelector(".product")
fetch("http://chst.vip:1234/api/getbaicaijiaproduct?titleid="+id)
.then(body=>body.json())
.then(res=>{
console.log(res)
res.result.forEach(item=>{
// console.log(item)
let regExp =  /^<[^<]+\s+src="([^''""]*)"/;
let url=item.productImg.match(regExp);
// console.log(url)
ela+=`<li>
<a href="" class="clearfix im">
    <div class="img fl">
        ${item.productImg}
    </div>
    <div class="infoR">
        <div class="title">            
                ${item.productName}            
            <div class="price">
                ${item.productPrice}
            </div>
        </div>
        <div class="down">
            <div class="bar">
                <div class="bar_in" style="width: 118px;">100%</div>
            </div>
            ${item.productCouponRemain}
            <div class="click">
                ${item.productCoupon}
                ${item.productHref}
            </div>
        </div>
    </div>
</a>
</li>`               
                })
        uu.innerHTML=ela;
})

// 进度条

let set=setTimeout(function(){
    let bar=document.querySelector('.bar_in');
    let width=bar.offsetWidth;
    console.log(width)
},3000)
     

        

    

